< Prev(J) / Next(K) > / View :

Filename: /text/sbasic/shared/03020405.xhp

(section: fileattr) (bookmark: bm_id3153380)
FileAttr function

FileAttr 関数

FileAttr Function [Runtime]
FileAttr 関数 [実行時](hd_id3153380.1)

Returns the access mode or the file access number of a file that was opened with the Open statement. The file access number is dependent on the operating system (OSH = Operating System Handle).
Open ステートメントでオープンしたファイルのファイルアクセス番号ないしアクセスモードを返します。ファイルアクセス番号は、オペレーティングシステムに依存します (OSH = Operating System Handle)。(par_id3154366.2)

(/section: fileattr)
Note Icon 注マーク If you use a 32-Bit operating system, you cannot use the FileAttr-Function to determine the file access number.
32 ビット系オペレーティングシステムを使用している場合、FileAttr 関数でファイルアクセス番号を取得することはできません。(par_id3153364.3)

See also: Open
次も参照してください:Open(par_id3163713.4)

Syntax:
構文:(hd_id3151116.5)

FileAttr (FileNumber As Integer, Attribute As Integer)
FileAttr (FileNumber As Integer, Attribute As Integer)(par_id3154012.6)

Return value:
戻り値:(hd_id3147349.7)

Integer
整数(par_id3146974.8)

Parameters:
パラメータ:(hd_id3153728.9)

FileNumber: The number of the file that was opened with the Open statement.
FileNumber: Open ステートメントでオープンしたファイルの番号。(par_id3151074.10)

Attribute: Integer expression that indicates the type of file information that you want to return. The following values are possible:
Attribute: 取得するファイル情報のタイプを指定する整数表式。ここには下記の値を指定できます。(par_id3144766.11)

1: The FileAttr-Function indicates the access mode of the file.
1: FileAttr 関数に、該当ファイルのアクセスモードを取得させます。(par_id3147396.12)

2: The FileAttr-Function returns the file access number of the operating system.
2: FileAttr 関数に、オペレーティングシステムのファイルアクセス番号を取得させます。(par_id3149959.13)

If you specify a parameter attribute with a value of 1, the following return values apply:
属性パラメータに 1 を指定した場合は、下記の戻り値が返されます。(par_id3154018.14)

1 - INPUT (file open for input)
1 - INPUT (入力用にファイルをオープン)(par_id3149124.15)

2 - OUTPUT (file open for output)
2 - OUTPUT (出力用にファイルをオープン)(par_id3156275.16)

4 - RANDOM (file open for random access)
4 - RANDOM (ランダムアクセス用にファイルをオープン)(par_id3155066.17)

8 - APPEND (file open for appending)
8 - APPEND (順編成用にファイルをオープン)(par_id3148406.18)

32 - BINARY (file open in binary mode).
32 - BINARY (バイナリモードでファイルをオープン)(par_id3154757.19)

(embed text/sbasic/shared/00000003.xhp#errorcode : linkinfo)

Error Codes

エラーコード(hd_id3152869.37)

(/embed text/sbasic/shared/00000003.xhp#errorcode)

(embed text/sbasic/shared/00000003.xhp#err5 : linkinfo)

5 Invalid procedure call
5 無効なプロシージャー呼び出しです (par_id3150891.41)

(/embed text/sbasic/shared/00000003.xhp#err5)

(embed text/sbasic/shared/00000003.xhp#err52 : linkinfo)

52 Bad file name or number
52 ファイル名または番号が不正です(par_id3154404.58)

(/embed text/sbasic/shared/00000003.xhp#err52)

Example:
例:(hd_id3147339.20)

Sub ExampleFileAttr
Sub ExampleFileAttr(par_id3155959.21)

Dim iNumber As Integer
Dim iNumber As Integer(par_id3145147.22)

Dim sLine As String
Dim sLine As String(par_id3153966.23)

Dim aFile As String
Dim aFile As String(par_id3155336.24)

aFile = "c:\data.txt"
aFile = "c:\data.txt"(par_id3163807.25)

iNumber = Freefile
iNumber = Freefile(par_id3154021.27)

Open aFile For Output As #iNumber
Open aFile For Output As #iNumber(par_id3153786.28)

Print #iNumber, "This is a line of text"
Print #iNumber, "This is a line of text"(par_id3155607.29)

MsgBox FileAttr(#iNumber, 1 ),0,"Access mode"
MsgBox FileAttr(#iNumber, 1 ),0,"Access mode"(par_id3150361.30)

MsgBox FileAttr(#iNumber, 2 ),0,"File attribute"
MsgBox FileAttr(#iNumber, 2 ),0,"File attribute"(par_id3149817.31)

Close #iNumber
Close #iNumber(par_id3155115.32)

End Sub
End Sub(par_id3147130.33)


< Prev / Next >